class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2023-02-10",
      revision: "4c211fe12728e523d36ed2d08d28245bfb1b576f"
  version "2023-02-10"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "d1cceced292cffcbbfc65804067257ee8ceda1bc813cdb46042cff091871fd6b"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "a688db5e7a5a7bfc081e96a3d95ca12c57e240e912cf902b573c356855b2b624"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "211a5539b8363b5386c9ddbf682295e7b4518a0d592d5e30cf762fd3717ca9ba"
    sha256 cellar: :any_skip_relocation, ventura:        "814b0e579fed3dbdba316feba0585e9cb283caca73139d7f8b0521f5f0072daf"
    sha256 cellar: :any_skip_relocation, monterey:       "eaf50b0652c59f43dafc4ac408ad52dd974d23e3b9f441f7a78b3f33693232ab"
    sha256 cellar: :any_skip_relocation, big_sur:        "eee326f61d54cd275cad19d1eab87b69bdc07ad5f5a9da807184630a9cbba64c"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "8098a600e318c303788d7e0df97384476902412be29525d9d63033aafa8cf4a7"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
